package io.wongxd.accessibility.utils

import android.accessibilityservice.GestureDescription
import io.wongxd.accessibility.AccessibilityApi
import io.wongxd.accessibility.viewfinder.ViewFinder

/**
 * # exceptions
 * 异常类合集
 */

/**
 * 视图搜索失败异常
 */
class ViewNodeNotFoundException : Exception {
    constructor(finder: ViewFinder<*>)
        : super("ViewNodeNotFound: ${finder.finderInfo()}")

    constructor(msg: String) : super(msg)
}

/**
 * 无障碍服务未运行异常
 * @constructor
 */
open class NeedAccessibilityException(name: String?) : RuntimeException("无障碍服务未运行: $name")

class NeedBaseAccessibilityException :
    NeedAccessibilityException(AccessibilityApi.BASE_SERVICE_CLS.name)

class NeedGestureAccessibilityException :
    NeedAccessibilityException(AccessibilityApi.GESTURE_SERVICE_CLS.name)

class GestureCanceledException(
    val gestureDescription: GestureDescription
) : RuntimeException()
